package com.cicc.springboot.service.impl;

import com.alibaba.excel.EasyExcel;

import com.cicc.springboot.entity.SrmSupplierBasicEntity;
import com.cicc.springboot.mapper.SupplierMapper;
import com.cicc.springboot.utile.SupplierBasicExcelListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Service
public class SupplierExcelImportServiceImpl<T> {
    @Autowired
    private SupplierMapper supplierMapper;

    // 供应商Excel导入
    public void importExcelData(MultipartFile file) throws IOException {
        SupplierBasicExcelListener listener = new SupplierBasicExcelListener(supplierMapper);
        // 使用 EasyExcel 解析文件，并使用自定义的监听器
        EasyExcel.read(file.getInputStream(), SrmSupplierBasicEntity.class, new SupplierBasicExcelListener(supplierMapper))
                .sheet(0)//读第几个工作表
                .headRowNumber(1)//跳过第一行读取数据
                .doRead();

    }


}
